﻿using System;
using Informator.Presentation.Common;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using System.Text.RegularExpressions;


namespace Informator.Presentation.Vesti
{
    /// <summary>
    /// Interaction logic for pgVesti.xaml
    /// </summary>
    
    /// ako ne redi treba dodati  HtmlAgilityPack  u reference 
    public partial class pgVesti : Page
    {

        public List<Vesti> listaVesti = new List<Vesti>();
        Button dugme = new Button();
        public pgVesti()
        {
            InitializeComponent();
            generisiHtmlNaslov();


        }


        public void generisiHtmlNaslov()
        {

            string a = "a";
            int broj = 9;
            for (int i = 0; i <= 15; i++)
            {        
                    VestAkt vst = new VestAkt();
                 
                    vst.NaslovV.Text = vst.listaVesti[i].naslov;
                    broj++;
                    vst.DatumV.Content = vst.listaVesti[i].datum; 
                    vst.TekstV.Text = vst.listaVesti[i].vest_detalji;

              

                    var row2 = new RowDefinition();
                    row2.Height = new GridLength(180);
                    aktuelne.RowDefinitions.Add(row2);
                    vst.btn.TabIndex = i;
                    vst.btn.Name = "btn" + i.ToString();
                
                  
                    Grid.SetRow(vst, i);

                    Animate.AddChild(vst, aktuelne);
    
           var converter = new System.Windows.Media.BrushConverter();
           var brush = (Brush)converter.ConvertFromString("#C0E5FF");
     


                    vst.btn.Click += btn_Click;
                    if (i == 1)
                    {
                        //vst.btn.Background = brush;
                        btn_Click(vst.btn, null);
                    }
                    

            }


        }

        public void color(Button ime)
        {
           
            var converter = new System.Windows.Media.BrushConverter();
            var brush2 = (Brush)converter.ConvertFromString("#FF2D3E4E");
            if (ime.Name != "btn1")
            {
                ime = dugme;
            }
            else
            {
                
                dugme.Background = brush2;
                MessageBox.Show(ime.Name);
            }
        }

        private void btnNazad_Click(object sender, RoutedEventArgs e)
        {
            Animate.SlideDownExit(this);
            Animate.ElementResponse(btnNazad);
            btnNazad.IsHitTestVisible = false;
           

        }
        private void btn_Click(object sender, RoutedEventArgs e)
        {
            
            VestAkt vst = new VestAkt();
            var dugme = sender as Button;
           // color(dugme);
        
           DatumV.Content = "Датум : " + vst.listaVesti[Convert.ToInt16(dugme.TabIndex)].datum;
           TekstV.Text = vst.listaVesti[Convert.ToInt16(dugme.TabIndex)].vest_tekst;
           NaslovV.Text = vst.listaVesti[Convert.ToInt16(dugme.TabIndex)].naslov;
           predmet.Text = "Предмет : " + vst.listaVesti[Convert.ToInt16(dugme.TabIndex)].vest_predmet;
        }

    }
}
